package com.ruoyi.park.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.park.domain.BoxInfo;
import com.ruoyi.park.service.IBoxInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗亭管理Controller
 * 
 * @author 博雅
 * @date 2023-12-11
 */
@RestController
@RequestMapping("/park/box")
public class BoxInfoController extends BaseController
{
    @Autowired
    private IBoxInfoService boxInfoService;

    /**
     * 查询岗亭管理列表
     */
    @PreAuthorize("@ss.hasPermi('park:box:list')")
    @GetMapping("/list")
    public TableDataInfo list(BoxInfo boxInfo)
    {
        startPage();
        List<BoxInfo> list = boxInfoService.selectBoxInfoList(boxInfo);
        return getDataTable(list);
    }

    /**
     * 导出岗亭管理列表
     */
    @PreAuthorize("@ss.hasPermi('park:box:export')")
    @Log(title = "岗亭管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoxInfo boxInfo)
    {
        List<BoxInfo> list = boxInfoService.selectBoxInfoList(boxInfo);
        ExcelUtil<BoxInfo> util = new ExcelUtil<BoxInfo>(BoxInfo.class);
        util.exportExcel(response, list, "岗亭管理数据");
    }

    /**
     * 获取岗亭管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('park:box:query')")
    @GetMapping(value = "/{boxId}")
    public AjaxResult getInfo(@PathVariable("boxId") Long boxId)
    {
        return success(boxInfoService.selectBoxInfoByBoxId(boxId));
    }

    /**
     * 新增岗亭管理
     */
    @PreAuthorize("@ss.hasPermi('park:box:add')")
    @Log(title = "岗亭管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoxInfo boxInfo)
    {
        return toAjax(boxInfoService.insertBoxInfo(boxInfo));
    }

    /**
     * 修改岗亭管理
     */
    @PreAuthorize("@ss.hasPermi('park:box:edit')")
    @Log(title = "岗亭管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoxInfo boxInfo)
    {
        return toAjax(boxInfoService.updateBoxInfo(boxInfo));
    }

    /**
     * 删除岗亭管理
     */
    @PreAuthorize("@ss.hasPermi('park:box:remove')")
    @Log(title = "岗亭管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{boxIds}")
    public AjaxResult remove(@PathVariable Long[] boxIds)
    {
        return toAjax(boxInfoService.deleteBoxInfoByBoxIds(boxIds));
    }
}
